attribute vec4 ece_Vertex;
attribute vec2 ece_TexCoord;
varying vec2 vTexCoord;
varying float vDistance;
varying vec3 vPosition;
varying mat3 vTBN;
void main() {
	gl_Position = ece_ModelViewProjectionMatrix * ece_Vertex;
	vPosition = vec3(ece_ModelViewMatrix * ece_Vertex);
	vDistance = length(gl_Position.xyz);
	//需要计算，这里是已经计算好的
	vec3 tangent = vec3(1.0, 0, 0); 
    vec3 binormal = vec3(0, 1.0, 0); 
	vec3 normal = vec3(0, 0, 1.0);
	
    // 使用顶点属性法线，并归一化
    //vec3 Normal = normalize(normal * 2.0 - 1.0);

	// 通过叉积来计算夹角
    //vec3 c1 = cross(Normal, vec3(0.0, 0.0, 1.0)); 
    //vec3 c2 = cross(Normal, vec3(0.0, 1.0, 0.0)); 
	
	// 方向朝外的是我们要的
    //if ( length(c1) > length(c2) ) { tangent = c1;	} else { tangent = c2;}
	
    // 归一化切线和次法线
    //tangent = normalize(tangent);
    //binormal = normalize(cross(normal, tangent)); 
    
    vec3 T = normalize(ece_NormalMatrix * tangent);
    vec3 B = normalize(ece_NormalMatrix * binormal);
    vec3 N = normalize(ece_NormalMatrix * normal);
    
    // 构造出 TBN 矩阵
    vTBN = mat3(T, B, N);
	vTexCoord = ece_TexCoord;
}